math: compile FP-free with BND_MATH_NO_FP (incl. the single header)#5
Merged
Conversation
Add BND_MATH_NO_FP: when set, the double (FP) engine and its <cmath> include compile out entirely, leaving the always-present integer/CORDIC engine to serve the full bnd::math API. The public surface, output grids, and types are unchanged — only the compute backend differs. Implied by BND_MATH_FIXED and auto-enabled on freestanding targets (__STDC_HOSTED__ == 0). - cmath_double.hpp resolves BND_MATH_NO_FP and gates <cmath> + the entire dbl engine behind it. The guard is at conditional depth, so the amalgamator keeps the <cmath> include inline under the same #ifndef — the SINGLE HEADER honors the FP-free path identically to the modular headers. - cmath.hpp dispatch and the constexpr BND_MATH_FN macro key on BND_MATH_NO_FP (every dbl:: reference already sat in the #else branch), so the integer engine is selected and constexpr whenever FP is unavailable. - New single_header_nofp_smoke target + CI step (Linux): compiles the single header with BND_MATH_NO_FP and a poison <cmath> shim placed first on the include path, so the build hard-errors if any <cmath> is pulled in. Verified it fires without the macro (genuine proof) and passes with it. - docs/math.md: document the FP-free build. Verified: default 397/397, CORDIC 440/440, nofp smoke builds+runs FP-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of the math-engine plan — the FP-free guard
Lets the library (and the single header) compile with no hardware floating point and no
<cmath>, leaving the always-present integer/CORDIC engine to serve the fullbnd::mathAPI. The public surface, output grids, and types are unchanged — only the compute backend differs.What
BND_MATH_NO_FPdoes#include <cmath>out entirely.BND_MATH_FIXED; auto-enabled when__STDC_HOSTED__ == 0(-ffreestanding).constexprunder it (the integer engine).How it works
cmath_double.hppresolves the macro and gates<cmath>+ the wholedblengine behind#ifndef BND_MATH_NO_FP. The guard is at conditional depth, so the amalgamator keeps the<cmath>include inline under the same guard — the single header honors the FP-free path identically to the modular headers (no longer hoisted unconditionally to the top).constexpr BND_MATH_FNmacro incmath.hppkey onBND_MATH_NO_FP. Everydbl::reference already sat in an#elsebranch, so the integer engine is selected cleanly.Proof (not just "it compiles")
New
single_header_nofp_smoketarget + Linux CI step compiles the single header with-DBND_MATH_NO_FPand a poison<cmath>shim first on the include path — the build hard-errors if any<cmath>is pulled in. Confirmed locally that it fires without the macro (genuine) and passes with it.Verification
single_header_nofp_smokebuilds & runs FP-free;single_header_smoke/single_header_freestanding_smokestill buildamalgamate_up_to_dategreen🤖 Generated with Claude Code